package com.hyb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hyb.Vo.StaffRoleVo;
import com.hyb.entity.StaffRole;
import com.hyb.mapper.StaffRoleMapper;
import com.hyb.service.StaffRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  员工角色Service接口实现类
 * </p>
 *
 * @author hyb
 * @since 2021-12-29
 */
@Service
public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole> implements StaffRoleService {

    @Autowired
    private StaffRoleMapper staffRoleMapper;

    @Override
    public void createStaffRoles(StaffRole staffRole) {
        staffRoleMapper.insert(staffRole);
    }

    @Override
    public void updateStaffRoles(StaffRoleVo staffRoleVo) {
        StaffRole staffRole = new StaffRole();
        staffRole.setStaffId(staffRoleVo.getStaffId());
        staffRole.setRoleId(staffRoleVo.getRoleId());
        QueryWrapper<StaffRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("staff_id",staffRoleVo.getStaffId());
        staffRoleMapper.update(staffRole,queryWrapper);
    }
}
